package work.timejay.entity;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import work.timejay.common.SuperModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;

import java.io.Serializable;

import lombok.Data;
import lombok.EqualsAndHashCode;
import work.timejay.dto.UserRegisterDTO;


/**
 * <p>
 *
 * </p>
 *
 * @author 王文杰
 * @since 2023-11-17
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("user")
public class User extends SuperModel<User> {

    private static final long serialVersionUID = 1L;

    /**
     * 手机号
     */
    @TableField("phone")
    private String phone;

    /**
     * 账户密码
     */
    @TableField("password")
    private String password;

    /**
     * 1 男 2 女
     */
    @TableField("sex")
    private Integer sex;

    /**
     * 用户姓名
     */
    @TableField("name")
    private String name;

    /**
     * 用户头像地址
     */
    @TableField("logo_path")
    private String logoPath;

    /**
     * 等级
     */
    @TableField("grade")
    private Integer grade;

    @TableField("remark")
    private String remark;

    /**
     * 1 账户正常 2 账户禁用
     */
    @TableField("status")
    private Integer status;

    /**
     * 点赞数
     */
    @TableField("give_num")
    private Long giveNum;

    /**
     * 文章数
     */
    @TableField("article_num")
    private Long articleNum;

    /**
     * 粉丝数
     */
    @TableField("fans_num")
    private Long fansNum;

    /**
     * 关注数
     */
    @TableField("like_num")
    private Long likeNum;

    /**
     * 账户是否初始化 0 未 1 已初始化
     */
    @TableField("init_status")
    private Integer initStatus;


    public static final String SEX = "sex";

    public static final String NAME = "name";

    public static final String LOGO_PATH = "logo_path";

    public static final String GRADE = "grade";

    public static final String DESC = "desc";

    public static final String STATUS = "status";

    public static final String GIVE_NUM = "give_num";

    public static final String ARTICLE_NUM = "article_num";

    public static final String FANS_NUM = "fans_num";

    public static final String LIKE_NUM = "like_num";

    public static User createEntityByRegister(UserRegisterDTO dto) {
        User bean = new User();
        bean.setPhone(dto.getPhone());
        bean.setPassword(dto.getPassword());
        bean.setSex(0);
        bean.setId(IdWorker.getId());
        bean.setCreateTime(LocalDateTime.now());
        bean.setUpdateTime(LocalDateTime.now());
        return bean;
    }

    @Override
    protected Serializable pkVal() {
        return null;
    }

}
